#include <stdio.h>
#include <sys/types.h>
#include <sys/signal.h>

int miredo_stop()
{
  pid_t miredopid;
  FILE *miredorun;

  miredorun = fopen("/var/run/miredo.pid", "r");
  if( miredorun == (FILE *)NULL )
    {
      printf("IPV6隧道未运行\n");
      return(-1);
    }

  if(fscanf( miredorun, "%d", &miredopid))
    {
      printf("miredo's pid = %d\n", miredopid);
      kill( miredopid, SIGQUIT);
      printf("SIGQUIT已发送到PID%d\n", miredopid);
      fclose( miredorun );
      return(1);
    }

  fclose( miredorun );
  return(0);

}
